import React from 'react';
import { TipsErrorModalNew } from '@/components/TipsErrorModalNew';
import { handleRevokeService } from './services';
import { message } from 'antd';
import { getTenantID } from '@/utils';
import { ILoadMapTypeAll } from '@/common';

export const RevokeModal = ({ resObj, revokeRequestUrl, onClose, reqBody = {}, modalTip, reloadRequest }) => {
  const handleRevokeCallback = (res) => {
    if (res?.msgFlag) {
      message?.success(res?.msg);
      reloadRequest();
    }
  };

  const { handleRevokeRun, handleRevokeLoading } = handleRevokeService(handleRevokeCallback, revokeRequestUrl);

  return (
    <TipsErrorModalNew
      onClose={onClose}
      modalOnOK={() => {
        const reqParams: Record<string, any> = {
          id: resObj?.id,
          workflowID: resObj?.workflowID,
          orderType: resObj?.orderType,
          businessType: resObj?.businessType,
          versionNum: resObj?.versionNum,
          paramObject: {
            procInstID: resObj?.workflowID,
            deleteReason: '放弃审核',
            checkResult: '放弃审核',
          },
          ...reqBody,
        };
        handleRevokeRun(reqParams);
      }}
      modalLoading={handleRevokeLoading}
      modalTip={modalTip}
    />
  );
};
